package com.lm.picocli.subcommands;

import picocli.CommandLine;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.Callable;

@CommandLine.Command(name = "read", description = "读取文件内容")
public class FileReadCommand implements Callable<Integer> {
    @CommandLine.Option(names = {"-p", "--path"}, description = "文件路径", required = true)
    private String filePath;

    @Override
    public Integer call() throws Exception {
        String content = new String(Files.readAllBytes(Paths.get(filePath)));
        System.out.println("文件内容:\n" + content);
        return 0;
    }
}